﻿// Type: D2L.Extensibility.AuthSdk.Impl.TimestampParser
// Assembly: D2L.Extensibility.AuthSdk, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null
// MVID: B2FBA42B-591C-474F-A782-6FF215FEDFB9
// Assembly location: C:\Users\leandro.perdizo\Desktop\D2L.Extensibility.AuthSdk.dll

using System.Text.RegularExpressions;

namespace D2L.Extensibility.AuthSdk.Impl
{
  internal class TimestampParser
  {
    internal bool TryParseTimestamp(string timestampMessage, out long result)
    {
      Match match = new Regex("Timestamp out of range\\s*(\\d+)", RegexOptions.Multiline).Match(timestampMessage);
      if (match.Success && match.Groups.Count >= 2)
      {
        result = long.Parse(match.Groups[1].Value);
        return true;
      }
      else
      {
        result = 0L;
        return false;
      }
    }
  }
}
